package com.study.jdk8v2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * <p>添加类描述</p>
 *
 * @author chentao
 * @version v 0.1 2021/2/21 17:10
 */
public class test2 {
    public static void main(String[] args) {
        List<Student> students = Arrays.asList(
                new Student("九天","男",5000,18,"天秤座"),
                new Student("十夜","男",4000,16,"双鱼座"),
                new Student("十一郎","男",3000,24,"水瓶座")
        );

        List<Student> list = filterStudent(students, new FilterProcess<Student>() {
            @Override
            public boolean process(Student student) {
                return student.getStar().equals("天秤座");
            }
        });
        for (Student student : list) {
            System.out.println(student);
        }


    }
    public static List<Student> filterStudent(List<Student> students, FilterProcess<Student> mp){
        List<Student> list = new ArrayList<>();

        for (Student student : students) {
            if(mp.process(student)){
                list.add(student);
            }
        }
        return list;
    }
}
